<?php

class log
{
    private $fhandle;
    
    public function write($msg){
        if(LOG_ENABLED){
            if(!$this->fhandle)
               $this->openLog();
            
            $time=date('Y-m-d H:i:s');
            fwrite($this->fhandle,$time.'  '.$msg."\r\n");  
        }   
    }
    private function openLog(){
        if(LOG_ENABLED){
            if(!$this->fhandle){
              $this->fhandle=fopen(LOG_FILE,'a');
              $this->write("\r\n\r\nSession Log created");
            }  
        }
    }

    private function closeLog(){
        if(LOG_ENABLED){
            if($this->fhandle)
              fclose($this->fhandle);
        } 
    }


}
